import axios from 'axios';
import qs from 'query-string';

export interface BizGoodsOrderId {
    id: number;
}

export interface BizGoodsOrderRecord {
    id: number;
    user_id: number;
    biz_goods_id: number;
    money: number;
    status: string;
    status_text: string;
    paid_at: string;
    created_at: string;
    updated_at: string;
    transaction_id: string;
    goods_title: string;
    goods_image: string;
    user_phone: string;
    user_nickname: string;
}

export interface BizGoodsOrderListRes {
    list: BizGoodsOrderRecord[];
    total: number;
}

export interface BizGoodsOrderParams {
    current: number;
    pageSize: number;
    goods_title?: string;
    phone?: string;
}

/**
 * 获取订单列表
 * @param params
 */
export function queryBizGoodsOrderList(params: BizGoodsOrderParams) {
    return axios.get<BizGoodsOrderListRes>('/admin/bizGoodsOrder/index', {
        params,
        paramsSerializer: (obj) => {
            return qs.stringify(obj);
        },
    });
}

/**
 * 获取订单详情
 * @param params
 */
export function queryBizGoodsOrderDetail(params: BizGoodsOrderId) {
    return axios.get<BizGoodsOrderRecord>('/admin/bizGoodsOrder/detail', {
        params,
        paramsSerializer: (obj) => {
            return qs.stringify(obj);
        },
    });
} 

export function queryBizGoodsOrderTickets(params: BizGoodsOrderId) {
    return axios.get('/admin/bizGoodsOrder/tickets', {
        params,
        paramsSerializer: (obj) => {
            return qs.stringify(obj);
        }
    });
}